package com.crm.controller;

import com.crm.dto.LogDto;
import com.crm.entity.Log;
import com.crm.result.PageResult;
import com.crm.result.PageResultTow;
import com.crm.result.Result;
import com.crm.service.LogService;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/monitor/operlog")
public class LogController {
    @Autowired
    private LogService logService;
    /**
     * 分页查询操作日志
     */
    @GetMapping("/list")
    public PageResultTow pageLog(LogDto logDto) {
        PageResult page =logService.pageLog(logDto);
        return PageResultTow.success(page.getRows(),page.getTotal());
    }
    /**
     * 删除日志列表
     */
    @DeleteMapping("/{operId}")
    public Result deleteLog(@PathVariable("operId") Integer operId) {
        logService.removeById(operId);
        return Result.success();
    }
    /**
     * 清空日志列表
     */
    @DeleteMapping("/clean")
    public Result cleanLog() {
        logService.cleanLog();
        return Result.success();
    }
}

